﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="InsertFTPDocument.aspx.cs" Inherits="Modules_FileManager_InsertFTPDocument" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Quản lý tài liệu</title>
</head>
<script type="text/javascript" src="/js/jquery.js"></script>
<script src="/js/colorpicker/js/colorpicker.js" type="text/javascript"></script>
<link href="/js/colorpicker/css/colorpicker.css" rel="stylesheet" type="text/css" />
<style type="text/css">
    #divTemplate label {
        float: left;
        width: 100px;
        border-bottom: 1px solid silver;
    }

    #divTemplate div {
        padding: 5px;
        width: 350px;
        vertical-align: top;
    }

    #divTemplate > div > div {
        float: left;
        width: 230px;
    }

    #divTemplate input {
        width: 230px;
    }

    #divTemplate textarea {
        width: 230px;
    }
</style>

<script type="text/javascript">
    //<![CDATA[
    function OnClientItemSelected(sender, args) {
        var jpathreplace = '<%=pathreplace%>'
            if (linkName == "")
                var docSrc = args.get_item().get_url().replace("?path=" + jpathreplace, "");
            $j("#txtLinkURL").val(docSrc);
            $j("#txtLinktext").val(args.get_item().get_name());
        }
        //]]>
</script>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <table cellpadding="0" cellspacing="0" width="730px">
            <tr>
                <td style="width: 410px;">
                    <telerik:RadFileExplorer ID="RadFileExplorer1" runat="server" EnableCreateNewFolder="true"
                        EnableCopy="true" Width="430px" Height="480px" OnClientItemSelected="OnClientItemSelected" EnableOpenFile="false">
                        <Configuration SearchPatterns="*.*" MaxUploadFileSize="104857600"></Configuration>
                    </telerik:RadFileExplorer>
                </td>
                <td style="vertical-align: top;">
                    <fieldset style="width: 280px; height: 460px;">
                        <legend>Thông tin tài liệu</legend>
                        <div style="padding: 40px 10px 50px 10px; width: 260px;">
                            <label for="selAlign" style="float: left; padding-right: 5px;">
                                Link text:</label>
                            <div style="float: left; height: 24px;">
                                <input type="hidden" id="txtLinkURL" value="" />
                                <input type="text" id="txtLinktext" value="" style="width: 200px;" />
                            </div>
                        </div>
                        <div style="text-align: center; width: 280px; padding-top: 50px;">
                            <input type="button" id="btnInsert" value="Chèn" onclick="Insert()" style="width: 80px;" />
                            <input type="button" id="btnCancel" value="Đóng lại" onclick="Cancel()" style="width: 80px; margin-left: 5px;" />
                        </div>
                    </fieldset>
                </td>
            </tr>
        </table>
    </form>
    <script language="javascript" type="text/javascript">
        function openWin(radWindow, url, title) {
            var oWnd = radopen(url, radWindow);
            oWnd.set_title(title);
        }
    </script>

    <!-- javascript -->
    <script type="text/javascript" language="javascript">
        var $j = jQuery.noConflict();

        // variables
        var linkUrl;
        var linkTarget = "_blank";
        var linkName = "";

        function getAllArgs() {
            linkUrl = $j("#txtLinkURL").val();
            linkTarget = "_blank";
            linkName = $j("#txtLinktext").val()
        }

        // init color picker
        $j(document).ready(function () {
            linkName = GetRadWindow().ClientParameters;
            if (linkName != "")
                $j("#txtLinktext").val(linkName);
        });

        // get current window
        function GetRadWindow() {
            if (window.radWindow) {
                return window.radWindow;
            }

            if (window.frameElement && window.frameElement.radWindow) {
                return window.frameElement.radWindow;
            }
            return null;
        }

        // Do insert
        function Insert() {
            // create object argument
            var oArg = new Object();

            // bind data to variables
            getAllArgs();

            // init object properties
            // init object properties
            oArg.linkUrl = linkUrl;
            oArg.linkTarget = linkTarget;
            oArg.linkName = linkName;
            oArg.IsCancel = false;

            // return object
            var oWindow = GetRadWindow();
            GetRadWindow().close(oArg);
        }

        // Do cancel
        function Cancel() {
            // create object argument
            var oArg = new Object();
            // init object properties
            oArg.IsCancel = true;
            // return object
            var oWindow = GetRadWindow();
            GetRadWindow().close(oArg);
        }
    </script>
</body>
</html>
